package com.source.exercise.lininumbersream;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.LineNumberInputStream;
import java.io.LineNumberReader;

/**
 * @Author wengqy
 * @Date 2021/1/29
 */
public class LineNumberInputStreamDemo {
    public static void main(String[] args) throws Exception {
        findRow();
    }

    public static void findRow() throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("D:\\代码\\springboot练习demo2020\\springboot\\bootparent\\daily-exercise\\说明.txt"));
        LineNumberReader lnr = new LineNumberReader(br);
        String str;
        int rowNum = 0;

        while ((str = lnr.readLine())!=null){
            System.out.println("当前为第"+lnr.getLineNumber()+"行,数据内容为:"+str);
            rowNum=lnr.getLineNumber();

        }
        System.out.println("循环完毕,总行数为:"+rowNum);
    }

}
